const{exec,escape}=require('../db/mysql')

const login=(username,password)=>{
    username=escape(username)
    password=escape(password)
    const sql=`
      select username,realname from users where username=${username} and password=${password}
    `;
    // console.log('sql is:',sql)
    return exec(sql).then(rows=>{
        return rows[0] || {}
    })
    //先使用假数据
    // if(username==='zhangsan'&&password==='123'){
    //     return true
    // }else{
    //     return false
    // }
}

module.exports={
    login
}